#pragma once
#include "..\AutoPtr\AutoPtr.h"
#include "AdjacentTable.h"
#include "TransitionTable.h"
#include "CharClass.h"

class DFA
{
public:
	int* AcceptStatus;
	NAutoPtr<TransitionTable> DFATable;

	DFA() : AcceptStatus(0){}

	~DFA()
	{
		if(AcceptStatus)
		{
			delete[] AcceptStatus;
		}
	}

	void BuildDfa(AdjancentTable<NAutoPtr<CharClass>> NFATable,CharClassList CharList);
	void PrintDFA();
	int Match(LPTSTR Expression);
protected:
	int** DStatus;
	int** DTran;
	int VerticeNum;
	int EdgeNum;
	int DStatusNumber;
	int DTranNumber;
	CharClassList CharList;

	int CompArray(int *t1, int *t2);
	int MinimizeDFAStates(int **Dtran, int *AcceptStates, int DtranNumber, int edgeNumber);
};